package com.tozed.android.launcher.simpleui;

import com.tozed.android.launcher.R;

import android.util.Log;
import android.view.View;

public class AddApplicationViewCache
{
	private static final String TAG = "AddApplicationViewCache";
	private static AddApplicationViewCache mAddApplicationViewCache = null;
	private View mAllAppsView = null;

	public static AddApplicationViewCache getInstance(){
		if (mAddApplicationViewCache == null)
			mAddApplicationViewCache = new AddApplicationViewCache();
		return mAddApplicationViewCache;
	}

	public void clear(){
		Log.i(TAG, "AddApplicationViewCache clear()");
		mAllAppsView = null;
	}

	public View getAllAppsView(){
		return mAllAppsView;
	}

	public void setAllAppsView(View view){
		Log.i(TAG, "AddApplicationViewCache setup AllAppsView");
		mAllAppsView = view;
	}
	
	public void updateAllAppsView(SimpleApplicationInfo appInfo, boolean removed){
		if (mAllAppsView != null){
			AddAppViewPager viewPager = (AddAppViewPager)mAllAppsView.findViewById(R.id.view_pager);
			if (viewPager != null)
				viewPager.updateCurrentPage(appInfo, removed);
		}
	}

	public void updateAllAppsViewData(){
		if (mAllAppsView != null){
			AddAppViewPager viewPager = (AddAppViewPager)mAllAppsView.findViewById(R.id.view_pager);
			if (viewPager != null)
				viewPager.updateAllAppsViewData();
		}
	}
}
